package net.lahuobao.mall.controller.admin;

import net.lahuobao.mall.entity.admin.MallOilsupplierEntity;
import net.lahuobao.mall.entity.admin.MallShopEntity;
import net.lahuobao.mall.service.admin.MallOilsupplierServiceI;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2017/4/10.
 */
@Controller
@RequestMapping("/mallOilsupplierController")
public class MallOilsupplierController extends BaseController{
    @Autowired
    private MallOilsupplierServiceI mallOilsupplierService;
    @RequestMapping(params = "chooseList")
    public ModelAndView list(HttpServletRequest request) {
        return new ModelAndView("net/lahuobao/mall/admin/oilSupplierChooseList");
    }
    @RequestMapping(params = "chooseDatagrid")
    public void datagrid(MallOilsupplierEntity mallOilsupplierEntity, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
        CriteriaQuery cq = new CriteriaQuery(MallOilsupplierEntity.class, dataGrid);

        //查询条件组装器
        if(StringUtil.isNotEmpty(mallOilsupplierEntity.getSuppliername())){
            cq.like("suppliername", "%"+mallOilsupplierEntity.getSuppliername()+"%");
            mallOilsupplierEntity.setSuppliername(null);
        }
        org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, mallOilsupplierEntity, request.getParameterMap());
        mallOilsupplierService.selectAll(cq, true);
        TagUtil.datagrid(response, dataGrid);
    }
}
